package com.example.exp_4_javaweb;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/addStudent")
public class addStudent extends HttpServlet {
    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");

        String name = request.getParameter("name");
        String passsword = request.getParameter("password");

        Student student = new Student(name,passsword);

        StudentHelper studentHelper = new StudentHelper(student);
        studentHelper.add();

        response.sendRedirect("main.jsp");
    }
}
